<script lang="ts" setup>
import {useConfirmDialog} from "@/hooks/DialogMsg";

const emit = defineEmits<{
  (e: 'tap'): void
}>()

const {confirm} = defineProps<{
  confirm?: string
}>()

function confirmOperate() {
  if (confirm && confirm.length > 0) {
    useConfirmDialog(confirm).then(state => {
      if (state === true) {
        emit('tap')
      }
    })
  } else {
    emit('tap')
  }
}
</script>
<template>
  <el-link @click="confirmOperate" v-bind="$attrs" underline type="primary">
    <slot name="default"></slot>
  </el-link>
</template>